﻿package _Pan3D.model{
	import flash.display.MovieClip;
	import flash.display.Loader;
	import flash.display.BitmapData
	import flash.display.Bitmap
	import flash.display.Sprite;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.net.URLVariables;
	import flash.net.URLRequestMethod;
	import flash.net.URLLoaderDataFormat
	import flash.events.IOErrorEvent;
	import flash.events.Event
	import flash.events.*
    
	
	import flash.display.GraphicsTrianglePath;
    import flash.display.IGraphicsPath;
    import flash.display.IGraphicsData;
    import flash.display.GraphicsBitmapFill;
    import flash.display.TriangleCulling;
    import flash.display.GraphicsStroke;
    import flash.display.GraphicsSolidFill;
	import flash.display.Graphics
	import flash.geom.Vector3D;
	
	import _Pan3D.cameras.Camera3D;
	import _Pan3D.base.Object3D
	import _Pan3D.base.stat_2D

	

	
    // --------------MSN:lation_pan@live.cn  QQ: 3423526------------- //

    public class M3D_Model_stat2D extends MovieClip {
		
		private var _Bmpsource:BitmapData //原始图像数据
		private var _triangles:GraphicsTrianglePath;        //存取三角形数据
		private var _base_vitem:Array = new Array();
		private var _vitem:Array = new Array();

		private var _v_array:Array = new Array();
		private var _u_array:Array = new Array();
		private var _uv_array:Array = new Array();
		
		private var _stringV:String
		private var _stringU:String
        private var _stringUV:String
		
		private var _Cam:Camera3D
		private var _this3d:stat_2D
		private var _load_pic:Loader = new Loader();
		private var _mc_circle:Sprite=new Sprite()
	
		public function M3D_Model_stat2D() {
			//this.addChild(_mc_circle)
			_mc_circle.graphics.beginFill(45845)
			_mc_circle.graphics.drawCircle(0,0,10)
		}
		public function _init(_tcam, _obj) {
            _Cam = _tcam;
			_this3d = _obj
			
			this.x=_Cam._fovw/2
			this.y=_Cam._fovh/2
		}
		public function _up_data() {
			
			math_change_point(_this3d)
			
			_mc_circle.x = _this3d.rx / (_this3d.rz + _Cam._br) * _Cam._br;
			_mc_circle.y = -_this3d.ry / (_this3d.rz + _Cam._br) * _Cam._br;
			
			
			var rz = _this3d.rz + _Cam._br
			var z_z = Math.sqrt(_this3d.rx*_this3d.rx+rz*rz);
			var z_k = Math.sqrt(z_z * z_z + _this3d.ry * _this3d.ry);
			_mc_circle.scaleX = _mc_circle.scaleY = _Cam._br / z_k * 0.5;
			
		}
		public function math_change_point(_3dpoint) {
			var rx = _3dpoint.x -_Cam.x 
			var ry = _3dpoint.y -_Cam.y
			var rz = _3dpoint.z -_Cam.z
	
			var tmp_rx = rx;
		
			rx = _Cam.cos_y * tmp_rx - _Cam.sin_y * rz;
			rz = _Cam.sin_y * tmp_rx + _Cam.cos_y * rz;
			
			var tmp_ry = ry;
			ry = _Cam.cos_x * tmp_ry - _Cam.sin_x * rz;
			rz = _Cam.sin_x * tmp_ry + _Cam.cos_x * rz;
				
			_3dpoint.rx = rx;
			_3dpoint.ry = ry;
			_3dpoint.rz = rz;
			
	
		}
		
		
	}
	
}